<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="d1">
<input type="text" id="d2">

<input type="button" value="加" onclick="f1()">
<input type="button" value="减" onclick="f2()">
<input type="button" value="乘" onclick="f3()">
<input type="button" value="除" onclick="f4()">

<div>
  结果 <span></span>
</div>

<script>
  function f1() {
    let i = document.querySelector("#d1");
    let a = document.querySelector("#d2");
    let v = document.querySelector("span");
    v.innerText =parseFloat(i.value)+parseFloat(a.value);
  }
  function f2() {
      let i = document.querySelector("#d1");
      let a = document.querySelector("#d2");
      let v = document.querySelector("span");
      v.innerText =i.value-a.value;
  }
  function f3() {
      let i = document.querySelector("#d1");
      let a = document.querySelector("#d2");
      let v = document.querySelector("span");
      v.innerText =i.value*a.value;
  }
  function f4() {
      let i = document.querySelector("#d1");
      let a = document.querySelector("#d2");
      let v = document.querySelector("span");
      v.innerText =i.value/a.value;
  }
</script>
</body>
</html>